package cn.stazxr.deepseekchat.utils;

import cn.stazxr.deepseekchat.config.DeepSeekConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Request Utils
 *
 * @author talentestors
 * @version 1.0
 * @since 2025.3.16
 **/
@Component
public final class RequestUtils {

	private static DeepSeekConfig config;

	@Autowired
	public RequestUtils(DeepSeekConfig configDemo) {
		RequestUtils.config = configDemo;
	}

	public static String getRequestUrl(String path) {
		String apiUrl = config.getApiUrl();
		StringBuilder url = new StringBuilder(apiUrl);
		// if url back with /, and path start with /, remove one /
		if (url.charAt(url.length() - 1) == '/') {
			url.deleteCharAt(url.length() - 1);
		}
		return url.append(path).toString();
	}

	public static String getApiKey() {
		return config.getApiKey();
	}

}
